package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.User;
import com.example.vo.RegisterUser;
import com.example.vo.ResetPasswordVO;
import com.example.vo.UserInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author circle48
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {
    User existsByPhone(String phone);

    int resetPassword(ResetPasswordVO user);

    User getUserById(Long userId);

    List<Long> getUserRoles(Long id);

    Long getIdByPhone(String phone);

    int register(RegisterUser user);

    String findUserNameByUserId(Long id);

    @Update("UPDATE user SET point = #{totalPoints} WHERE id = #{id}")
    void updataUserIntegration(@Param("totalPoints") int totalPoints, @Param("id") Long id);

    @Select("SELECT * FROM user WHERE id = #{userId}")
    UserInfoVo getUserInfoById(Long userId);

    @Update("UPDATE user SET profile = #{avatar} WHERE id = #{userId}")
    int updateProfile(Long userId, String avatar);

    @Update("UPDATE user SET password = #{encodePassword} WHERE id = #{userId}")
    int updatePassword(Long userId, String encodePassword);

    @Update("UPDATE user SET nick_name = #{nickname} WHERE id = #{userId}")
    int updateUserInfo(Long userId, String nickname);
}




